-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve usability of the SpriteFramesEditor #80448
base: master
Are you sure you want to change the base?
Conversation
ce01fe5
to
9c989da
Compare
9c989da
to
cb2de7b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to check that you actually applied the suggestions, pay attention to detail :)
038b3bb
to
19a46ee
Compare
0ee6b62
to
d78b48b
Compare
@AThousandShips ok, did the requested changes, saving only dominant parameter related to the spin box that was mofied!
Also thank you very much for explaining me how the |
dominant_param = int(EditorSettings::get_singleton()->get_project_metadata("sprite_frames", "dominant_param", -1)); | ||
if (dominant_param == PARAM_SIZE) { | ||
split_sheet_size_x->set_value(split_data["dom_x"]); | ||
split_sheet_size_y->set_value(split_data["dom_y"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to compute the other values here (i.e. count for x/y and vice versa), including the ranges for sep/offset
I believe, otherwise it looks good, will take a deeper look when I have time!
To ensure correctness I'd also suggest using wildly different sized textures to see what happens when you swap over and catch nasty cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry didnt understood, the sep/offset is below outside the if statement, you mean compute them before? the dominants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also I have found a problem, if you close the project and open again, the dominant values are set, but the others, lets suppose dominant is hor/vert
then size x/y
is saved, and when open the project the size x/y
is set_value
but hor/vert
is not calculated, didnt understood why!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See here:
godot/editor/plugins/sprite_frames_editor_plugin.cpp
Lines 446 to 460 in 7df3933
case PARAM_SIZE: { | |
const Size2i frame_size = _get_frame_size(); | |
const Size2i offset_max = texture_size - frame_size; | |
split_sheet_offset_x->set_max(offset_max.x); | |
split_sheet_offset_y->set_max(offset_max.y); | |
const Size2i sep_max = size - frame_size * 2; | |
split_sheet_sep_x->set_max(sep_max.x); | |
split_sheet_sep_y->set_max(sep_max.y); | |
const Size2i separation = _get_separation(); | |
const Size2i count = (size + separation) / (frame_size + separation); | |
split_sheet_h->set_value(count.x); | |
split_sheet_v->set_value(count.y); |
godot/editor/plugins/sprite_frames_editor_plugin.cpp
Lines 463 to 477 in 7df3933
case PARAM_FRAME_COUNT: { | |
const Size2i count = _get_frame_count(); | |
const Size2i offset_max = texture_size - count; | |
split_sheet_offset_x->set_max(offset_max.x); | |
split_sheet_offset_y->set_max(offset_max.y); | |
const Size2i gap_count = count - Size2i(1, 1); | |
split_sheet_sep_x->set_max(gap_count.x == 0 ? size.x : (size.x - count.x) / gap_count.x); | |
split_sheet_sep_y->set_max(gap_count.y == 0 ? size.y : (size.y - count.y) / gap_count.y); | |
const Size2i separation = _get_separation(); | |
const Size2i frame_size = (size - separation * gap_count) / count; | |
split_sheet_size_x->set_value(frame_size.x); | |
split_sheet_size_y->set_value(frame_size.y); |
and when open the project the size x/y is set_value but hor/vert is not calculated, didnt understood why!
The min/max of the sep/offset values are updated here and should be done so here as well IMO
and when open the project the size x/y is set_value but hor/vert is not calculated, didnt understood why!
This is exactly what I'm talking about, they need to be calculated, see the code I referenced for how it is done
d78b48b
to
4719367
Compare
@@ -458,6 +471,9 @@ void SpriteFramesEditor::_sheet_spin_changed(double p_value, int p_dominant_para | |||
const Size2i count = (size + separation) / (frame_size + separation); | |||
split_sheet_h->set_value(count.x); | |||
split_sheet_v->set_value(count.y); | |||
|
|||
split_data["dom_x"] = int(split_sheet_h->get_value()); | |||
split_data["dom_y"] = int(split_sheet_v->get_value()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now reversed, when PARAM_SIZE
you store the size, and calculate the other value, and vice versa
The split_sheet_x/y
should be calculated from the texture size, and vice versa, when loading
Is this intended that changing spritesheet will reset the values to default? |
file_split_sheet->popup_file_dialog(); | ||
} else { | ||
// If there's a path to a texture goto the editor directly! | ||
String path = EditorSettings::get_singleton()->get_project_metadata("sprite_frames", "last_texture", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is last texture remembered globally? Is it so common to use a single texture between editor sessions?
if (updating_split_settings) { | ||
return; | ||
} | ||
updating_split_settings = true; | ||
|
||
if (p_dominant_param != PARAM_USE_CURRENT) { | ||
dominant_param = p_dominant_param; | ||
EditorSettings::get_singleton()->set_project_metadata("sprite_frames", "dominant_param", dominant_param); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EditorSettings::get_singleton()->set_project_metadata("sprite_frames", "dominant_param", dominant_param); | |
EditorSettings::get_singleton()->set_project_metadata("sprite_frames_editor", "dominant_param", dominant_param); |
Makes its purpose more clear.
(remember to replace other references too)
} break; | ||
} | ||
|
||
// Save relevant data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Save relevant data | |
// Save relevant data. |
bool new_texture = texture != split_sheet_preview->get_texture(); | ||
split_data = EditorSettings::get_singleton()->get_project_metadata("sprite_frames", "split_data", Dictionary()); | ||
String last_texture = EditorSettings::get_singleton()->get_project_metadata("sprite_frames", "last_texture", ""); | ||
bool has_valid_data = (split_data != Dictionary() && last_texture != ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool has_valid_data = (split_data != Dictionary() && last_texture != ""); | |
bool has_valid_data = (!split_data.is_empty() && !last_texture.is_empty()); |
split_sheet_offset_x->set_max(size.x); | ||
split_sheet_offset_y->set_max(size.y); | ||
|
||
updating_split_settings = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this flag if you use set_value_no_signal()
.
} | ||
|
||
updating_split_settings = false; | ||
|
||
// Reset zoom. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's done for a specific purpose, this comment would need to be clarified. Otherwise you can remove it, as it's obvious from the method name.
@@ -1896,7 +1942,7 @@ SpriteFramesEditor::SpriteFramesEditor() { | |||
load->set_shortcut_context(frame_list); | |||
load->set_shortcut(ED_SHORTCUT("sprite_frames/load_from_file", TTR("Add frame from file"), KeyModifierMask::CMD_OR_CTRL | Key::O)); | |||
load_sheet->set_shortcut_context(frame_list); | |||
load_sheet->set_shortcut(ED_SHORTCUT("sprite_frames/load_from_sheet", TTR("Add frames from sprite sheet"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::O)); | |||
load_sheet->set_shortcut(ED_SHORTCUT("sprite_frames/load_from_sheet", TTR("Add frames from sprite sheet | (Shift + Click) to load new texture"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::O)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can't be added like that, because it becomes a part of shortcut's name:
Instead you should use set_tooltip_text()
for the note.
load_sheet->set_shortcut(ED_SHORTCUT("sprite_frames/load_from_sheet", TTR("Add frames from sprite sheet | (Shift + Click) to load new texture"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::O)); | |
load_sheet->set_shortcut(ED_SHORTCUT("sprite_frames/load_from_sheet", TTR("Add frames from sprite sheet"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::O)); | |
load_sheet->set_tooltip_text("Shift + Click: Load new texture.") |
btw the way it is implemented, if a shortcut includes Shift (like the default one), the file dialog will be opened when you press it.
Currently when the user is adding a lot of animations in the SpriteFramesEditor he has to open the sprite everytime and set values all again:
PR-usability-1.mp4
with the changes of this PR, I tried to make it as more reliable as possible, the editor will "save" the settings and know the settings and last texture used in the process:
PR-usability-2.mp4
Some info:
Add frames from spritesheet
it will open theOpen a file
to select a new textureBugsquad edit: